//
//  NSObject+QL.m
//  QLTiyufeng_IOS
//
//  Created by anan on 14-8-29.
//  Copyright (c) 2014年 baobaodev_anan. All rights reserved.
//

#import "NSObject+QL.h"

@implementation NSObject (QL)

-(id)objectFromJSONString
{
    NSError *error = [[NSError alloc] init];
    if ([self class]==[NSString class]) {
        id data = [NSJSONSerialization JSONObjectWithData:[(NSString*)self dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
        return data;
    }
    return nil;
}

- (NSString*)JSONString
{
    NSError *error = [[NSError alloc] init];
    NSData* data = [NSJSONSerialization dataWithJSONObject:self options:kNilOptions error:&error];
    NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];;
    return json;
}

@end
